using System.Drawing;
using Microsoft.VisualStudio.Modeling.Diagrams;
using Microsoft.VisualStudio.Modeling;

namespace Dslfactory.wcfLanguage
{
 using Properties;

 public partial class MessageContractShapeBase
 {
  /// <summary>
  /// Represented MessageContract class
  /// </summary>
  public MessageContract MessageContract
  {
   get
   {
    return ModelElement as MessageContract;
   }
  }
 }


 public partial class MessageContractShape
 {
  /// <summary>
  /// Changes the delegate used to obtain the icon of the Method in an Interface shape
  /// </summary>
  /// <param name="melType"></param>
  /// <returns></returns>
  protected override CompartmentMapping[] GetCompartmentMappings(System.Type melType)
  {
   CompartmentMapping[] mappings = base.GetCompartmentMappings(melType);
   ElementListCompartmentMapping operationMapping = mappings[0] as ElementListCompartmentMapping;
   operationMapping.ImageGetter = GetElementImage;
   operationMapping.ElementListGetter = GetElements;
   return mappings;
  }


  /// <summary>
  /// Decides what the icon of the method will be in the interface shape
  /// </summary>
  /// <param name="mel"></param>
  /// <returns></returns>
  new Image GetElementImage(ModelElement mel)
  {
   MessageMember member = mel as MessageMember;
   if ( (member == null) || (member.MessageMemberKind== MessageMemberKind.Normal))
    return base.GetElementImage(mel);

   switch (member.Kind)
   {
    case DataMemberKind.Field:
     switch (member.Visibility)
	    {
		    case Visibility.Public:
        return Resources.DataContract_Field;
      
      case Visibility.Protected:
        return Resources.DataContract_Field_Protected;
      
      case Visibility.Private:
        return Resources.DataContract_Field_Private;

      case Visibility.Internal:
        return Resources.DataContract_Field_Sealed;

      default:
        return Resources.DataContract_Field;
	    }

    case DataMemberKind.Property:
     switch (member.Visibility)
	    {
		    case Visibility.Public:
        return Resources.DataContract_Properties;
      
      case Visibility.Protected:
        return Resources.DataContract_Properties_Protected;
      
      case Visibility.Private:
        return Resources.DataContract_Properties_Private;

      case Visibility.Internal:
        return Resources.DataContract_Properties_Sealed;

      default:
        return Resources.DataContract_Properties;
     }

    default:
     return base.GetElementImage(mel);
   }
  }
 }
}
